Fix/recursive-blacklist-check#44
Merged
IvanMurzak merged 9 commits intomainfrom Jan 4, 2026
Merged
Conversation
…nd support blacklisted generic interface arguments
… prevent redundant checks
…ion logic to handle blacklisted types
… improve blacklist check logic
Contributor
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the type blacklist checking mechanism in ReflectorNet by adding recursive checks for generic type arguments and implementing a caching layer for performance optimization.
Key Changes:
- Adds caching mechanism to avoid redundant blacklist checks for the same types
- Implements recursive checking for generic type arguments in interfaces and base classes
- Adds protection against infinite recursion using a visited set
- Optimizes array element serialization to skip blacklisted items
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 10 comments.
| File | Description |
|---|---|
| ReflectorNet/src/Reflector/Reflector.Registry.cs | Implements caching and recursive blacklist checking logic with cycle detection |
| ReflectorNet/src/Converter/Reflection/ArrayReflectionConverter.cs | Adds runtime type checking to serialize blacklisted array elements as null |
| ReflectorNet.Tests/src/ReflectorTests/IsTypeBlacklistedTests.cs | Adds comprehensive tests for generic interfaces with blacklisted type arguments and inheritance scenarios |
| ReflectorNet.Tests/src/ReflectorTests/BlacklistedArrayItemTests.cs | Adds tests verifying blacklisted array elements are properly handled as null values |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…better immutability and thread safety
…ent race conditions
…e conditions and memory growth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request enhances the blacklisting functionality in the ReflectorNet library, focusing on more robust and efficient detection of blacklisted types—including those involved in generics, inheritance, and interface implementations. It introduces a caching mechanism for blacklist checks, improves array serialization behavior for blacklisted elements, and adds comprehensive tests for these scenarios.
Blacklisting logic and performance improvements:
_blacklistCache) to theRegistryclass to speed up repeated blacklist checks and ensure cache is cleared whenever the blacklist is updated. Blacklist checks now use a recursive, cycle-safe method that covers inheritance, interfaces, arrays, and generics. [1] [2] [3] [4] [5]Array serialization behavior:
ArrayReflectionConverterto serialize blacklisted array elements asnull, ensuring that arrays containing blacklisted types are handled gracefully during serialization.Test coverage enhancements:
BlacklistedArrayItemTeststo verify that arrays with blacklisted items serialize those elements asnulland thatSerializedMemberListstringifies lists with nulls correctly.IsTypeBlacklistedTeststo cover scenarios involving generic interfaces with blacklisted type arguments, inheritance from generics with blacklisted arguments, and deep inheritance chains, ensuring all edge cases are detected. [1] [2] [3]